import numpy as np
import pandas as pd
import collections
import datetime
from read_table import read_table
table = read_table()
table["1"]
for i in range(1, 11):
table[str(i)]['date'] = pd.to_datetime(table[str(i)]['time'], format = "%Y/%m/%d", errors = 'coerce')
for i in range(1, 11):
temp = table[str(i)]["time"].apply(lambda x: x.split("/"))
temp = np.array(temp)
demp = []
for j in range(0, temp.shape[0]):
temp[j][0] = str(int(temp[j][0]))
temp[j][1] = str(int(temp[j][1]))
temp[j][2] = str(int(temp[j][2]))
demp.append("/".join(temp[j]))
table[str(i)]["date"] = demp
table["1"]
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use("seaborn")
def print_k_line():
for i in range(1, 11):
opens = [q for q in table[str(i)]["open"]]
high = [q for q in table[str(i)]["high"]]
low = [q for q in table[str(i)]["low"]]
close = [q for q in table[str(i)]["close"]]
# turnover = [q/10000000 for q in table["1"]["turnover"]]
dates = [datetime.datetime.strptime(q ,"%Y/%m/%d") for q in table[str(i)].date]
fig = plt.figure(figsize=(20,10), dpi=300)
ax = fig.add_subplot(111)
ax.plot_date(dates, opens, color='b',linestyle='-',marker='o', label='open')
ax.plot_date(dates, close, color='r',linestyle='-',marker='o', label='close')
ax.plot_date(dates, high, color='g',linestyle='--',marker='v', label='high')
ax.plot_date(dates, low, color='coral',linestyle='--',marker='v', label='low')
# ax.plot_date(dates, turnover, color='black',linestyle='-',marker='.', label='volume')
plt.title("")
plt.legend()
fig.autofmt_xdate()
plt.show()
print_k_line()